<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  table {
    width: 50%;
    border-collapse: collapse;
    border: 1px solid #ccc;
    text-align: center;
  }

  table tr th {
    border-collapse: collapse;
    border: 1px solid #ccc;
  }

  table tbody td {
    border-collapse: collapse;
    border: 1px solid #ccc;
  }
</style>
<script src="../vue.js"></script>

<body>
  <div id="app">
    <button @click="add">添加学生</button>
    <button @click="del">删除学生</button>
    <table>
      <tr>
        <th>班级</th>
        <th>姓名</th>
        <th>性别</th>
        <th>年纪</th>
      </tr>
      <tr v-for="item in student" align="content">
        <td>{{item.grade}}</td>
        <td>{{item.sName}}</td>
        <td>{{item.gender}}</td>
        <td>{{item.age}}</td>
      </tr>
    </table>
  </div>
  <script>
    const vm = new Vue({
      el: "#app",
      data: {
        student: []
      },
      methods: {
        add() {
          const student = {
            grade: "1",
            sName: "ZhangSan",
            gender: "male",
            age: "25"
          }
          this.student.push(student);
        },
        del() {
          this.student.pop(student);
        }
      }
    })
  </script>
</body>

</html>